    var stream = {
    info: {
    playtime : 8000,
    playbtn : '#playbtn',
    container: '#hupu-stream',
    streamObject:'#HCFull',
    cookie: 'nbahupustream',
    bgcolor:null,
    isfloat:0,
    isvideo:0,
    sourcevideolink:null,
    width:980,
    schuler:null,
    streamtimer:null,
    height:400
    },
    init :  function(param){
    this.info = $.extend(this.info, param);
    if (this.info.streamObject.substr(0,1)!='#') {
    this.info.streamObject = '#'+this.info.streamObject;
    }

    if (this.info.playbtn.substr(0,1)!='#') {
    this.info.playbtn = '#'+this.info.playbtn;
    }

    bgcolor = '';
    if (typeof(this.info.bgcolor) != 'undefined' && this.info.bgcolor){
    bgcolor = 'background:'+this.info.bgcolor+';';
    }

    <!-- $(this.info.container).empty(); -->
    if (this.info.isfloat) {
    $(this.info.container).html(this.getFloatStreamHtml(bgcolor));
    this.autoPlayFloatStream();
    }else if(this.info.isvideo){
    var sourceHtml = this.getVideoPlayBtn()
    + '<div id="'+this.info.streamObject.replace('#', '')+'" style="margin: 0pt auto; display:none;width:'+this.info.width+'px; height:400px;position: relative;cursor:pointer;background:'+this.info.bgcolor+' url(' + this.info.sourcevideologourl + ') center center no-repeat;">'
        + '<div class="video-wrap" id="video1" style="width:415px;margin:0 0 0 285px;padding-top:35px;">'
            + this.getVideoStreamHtml()
            + '</div>'
        + '</div>';
    $(this.info.container).html(sourceHtml);
    <!-- stream.getPlayNum(); -->
    this.autoPlayVideoStream();

    }
    else
    {
    var sourceHtml = this.getPlayBtnHtml()
    + '<div id="'+this.info.streamObject.replace('#', '')+'" style="margin: 0pt auto; width:'+this.info.width+'px;display: none; position: relative;background:#fff;'+bgcolor+'">'
        + this.getCloseBtnHtml()
        +'<div class="aStartPlay">'
            + this.getContentHtml()
            +'</div>'
        + '</div>';
    $(this.info.container).html(sourceHtml);
    this.autoplay();
    }
    },
    ckplayer_status:function ckplayer_status(str){
    document.getElementById('video1').value=str+'\n'+document.getElementById('video1').value;
    },
    isIE : function( version, comparison ){
    var $div = $('<div style="display:none;"/>').appendTo($('body'));
    $div.html('<!--[if '+(comparison||'')+' IE '+(version||'')+']><a>&nbsp;</a><![endif]-->');
    var ieTest = $div.find('a').length;
    $div.remove();
    return ieTest;
    },
    appendJs:function(src,callback){
    var head= document.getElementsByTagName('head')[0];
    var script= document.createElement('script');
    script.type= 'text/javascript';

    script.onreadystatechange= function () {
    if (this.readyState == 'loaded')
    callback && callback();
    }
    script.onload= function(){
    callback && callback();
    }
    script.src= src;
    head.appendChild(script);
    },
    autoplay:function (){
    if($(this.info.streamObject).is(":visible") == true) return '';
    var playNum = parseInt(this.getPlayNum());
    if (playNum < this.info.autoplaynum)
    {
    playNum += 1;
    setTimeout(function(){stream.play();}, 3000);
    this.setPlayNum(playNum);
    }
    },
    play:  function(){
    var self = this;
    if ($(this.info.streamObject).is(":visible") == true) return'';
    $('.aStartPlay').html(this.getContentHtml());
    $(this.info.streamObject).slideDown(1500,function(){
    $(self.info.streamObject).css({
    'display':'block',
    height:'400px'
    });
    });


    $(this.info.playbtn).hide();
    this.info.schuler = setTimeout(function(){stream.close();}, this.info.playtime);
    },

    close:  function(){
    var self = this;
    if ($(this.info.streamObject).is(":visible") == false){
    return '';
    }
    $(this.info.streamObject).slideUp(1000, function(){

    });
    clearTimeout(this.schuler);
    $('#hidebtn').css('zIndex',1);
    $(this.info.playbtn).show();
    },

    autoPlayFloatStream:function(){
    if ($("#HCFull").is(":visible") == true) return '';
    if (playNum < this.info.autoplaynum)
    {
    playNum += 1;
    setTimeout(function(){stream.playFloatStream();}, 2000);
    this.setPlayNum(playNum);
    }
    },
    autoPlayVideoStream:function(){
    if ($("#HCFull").is(":visible") == true) return '';

    var playNum = parseInt(this.getPlayNum());
    if (playNum < this.info.autoplaynum)
    {
    playNum += 1;
    setTimeout(function(){stream.playVideo();}, 5000);
    this.setPlayNum(playNum);
    }
    },
    playFloatStream:function(){
    if ($(this.info.streamObject).is(":visible") == true) return '';
    $('#361_du').html(this.getContentHtml());
    $('#HCFull').slideDown("1000");
    $("#HCFull").show();
    $("#hidebtn").show();
    $("#viewbtn").hide();
    clearTimeout(this.streamtimer);
    this.info.streamtimer = setTimeout(function(){stream.closeFloatStream();}, this.info.playtime);
    },
    playVideo :  function(){
    var self = this;
    if ($(this.info.streamObject).is(":visible") == true) return'';
    $('.video-wrap').html(self.getVideoStreamHtml);
    $(this.info.streamObject).slideDown(1500,function(){
    $(self.info.streamObject).css({
    'display':'block',
    height:'400px'
    });
    });
    $(this.info.streamObject).unbind('click').bind('click',function(){

    window.open(stream.info.sourcevideologolink);
    });

    $('.video-wrap').click(function(e){
    e.stopPropagation();
    })

    $(this.info.playbtn).hide();
    $('#hidebtn').css('zIndex',2);
    this.info.schuler = setTimeout(function(){stream.closeVideo();}, this.info.playtime);

    },
    closeFloatStream:function(){
    if ($(this.info.streamObject).is(":visible") == false) return '';
    $("#361_du").empty();
    clearTimeout(this.info.streamtimer);
    $("#HCFull").hide();
    $("#hidebtn").hide();
    $("#viewbtn").show();
    },
    closeVideo:  function(){
    var self = this;
    if ($(this.info.streamObject).is(":visible") == false){
    return '';
    }
    $(this.info.streamObject).slideUp(1000, function(){
    $('.video-wrap').empty();
    });

    clearTimeout(this.info.schuler);
    $('#hidebtn').css('zIndex',1);
    $(this.info.playbtn).show();
    },
    getFloatStreamHtml:function(bgcolor){
    var html = '<div class="ad980-60" style="height:auto;margin-bottom:0px;position:relative;z-index:4;width:'+this.info.width+'px;margin:0 auto;">'
        + '<div id="divplay" style="position:absolute; display: block; margin: 0pt auto; width: '+this.info.width+'px;z-index:5;">'
            + '<div id="viewbtn"  onClick="stream.playFloatStream()" style="position: absolute; width: 20px; height: 50px; cursor: pointer; background-image: url(\'http://w1.hoopchina.com.cn/index/images/uparrow.gif\'); right:-25px; top:0;z-index:2"></div>'
            + '<div id="hidebtn" onClick="stream.closeFloatStream()" style="position: absolute; width: 20px; height: 50px;display:none; right: -25px;z-index:4; top: 0; background-image:url(\'http://w1.hoopchina.com.cn/index/images/closearrow.gif\'); cursor: pointer;z-index:1"></div>'
            + '</div>'
        + '<div id="'+this.info.streamObject.replace('#', '')+'" style="position: absolute;margin: 0pt auto; display: none; width: '+this.info.width+'px; z-index:98;left:0px;top:0px;height:350px;'+bgcolor+'">'
            + '<div id="361_du" style="position: absolute;top:0;left:0;z-index:2;width:'+this.info.width+'px; height:'+this.info.height+'px;overflow:hidden;">'
                + this.getContentHtml()
                + '</div>'
            + '</div></div>';
    return html;
    },
    getPlayNum:function() {
    var arr = document.cookie.match(new RegExp("(^| )"+this.info.cookie+"=([^;]*)(;|$)"));

    if(arr != null) {
    return unescape(arr[2]);
    } else {
    return 0;
    }
    },
    setPlayNum:function(playNum) {
    var exp  = new Date();
    exp.setTime(exp.getTime() + this.info.lifeday*24*60*60*1000);
    document.cookie = this.info.cookie + "="+ escape (playNum) + ";expires=" + exp.toGMTString();
    },
    getContentHtml:function() {
    var content = this.info.type == 'flash'? this.getFlashStreamHtml(): this.getImageStreamHtml();
    return content;
    },
    getPlayBtnHtml:function () {
    return '<div id="divplay" onClick="stream.play()" style="position:relative; display: block; margin: 0pt auto; width: 980px;z-index:10;"><div id="'+this.info.playbtn.replace('#', '')+'" style="position: absolute; width: 20px; height: 50px; cursor: pointer; background-image: url(\'http://w1.hoopchina.com.cn/index/images/uparrow.gif\'); right:-25px; top:0;z-index:2"></div></div>';
    },
    getCloseBtnHtml:function (){
    return '<div id="hidebtn" onclick="stream.close()" class="absolute" style="position: absolute; width: 20px; height: 50px; right: -25px; top: 0; background-image:url(\'http://w1.hoopchina.com.cn/index/images/closearrow.gif\'); cursor: pointer;"></div>';
    },
    getVideoPlayBtn:function () {
    return '<div id="divplay" onClick="stream.playVideo()" style="position:relative; display: block; margin: 0pt auto; width: 980px;z-index:10;"><div id="'+this.info.playbtn.replace('#', '')+'" style="position: absolute; width: 20px; height: 50px; cursor: pointer; background-image: url(\'http://w1.hoopchina.com.cn/index/images/uparrow.gif\'); right:-25px; top:0;z-index:2"></div><div id="hidebtn" onclick="stream.closeVideo()" class="absolute" style="position: absolute; width: 20px; height: 50px; right: -25px; top: 0; background-image:url(\'http://w1.hoopchina.com.cn/index/images/closearrow.gif\'); cursor: pointer;z-index:1;"></div></div>';
    },
    getImageStreamHtml:function(){
    return '<a href="'+this.info.sourcelink+'" target="_blank"><img src="'+this.info.sourceurl+'" width="'+this.info.width+'" height="'+this.info.height+'"></a>';
    },
    getFlashStreamHtml:function(){
    return '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+this.info.width+'" height="'+this.info.height+'"><param name="movie" value="'+this.info.sourceurl+'" /><param name="quality" value="high" /><param value="never" name="AllowScriptAccess"><param value="opaque" name="wmode"><param name="wmode" value="transparent" /><embed src="'+this.info.sourceurl+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="'+this.info.width+'" height="'+this.info.height+'"></embed></object>';
    },
    loadedHandler : function loadedHandler(){

    stream.status = true ;
    CKobject.getObjectById('ckplayer_video1').addListener('paused','stream.pausedHandler');
    if(CKobject.getObjectById('ckplayer_video1').getType()){
    CKobject.getObjectById('ckplayer_video1').addListener('time',stream.timeHandler);
    }else{
    CKobject.getObjectById('ckplayer_video1').addListener('time','stream.timeHandler');
    }
    },
    watchTime : 0,
    setT : null,
    status : false,
    pausedHandler : function (b){
    if(stream.setT){
    window.clearInterval(stream.setT);

    }
    if(!b){
    stream.setT = window.setInterval(stream.setFunction,1000);
    }
    },
    timeHandler:function(t){
    if( t*1000 >= (stream.info.playtime-2000) ){
    setTimeout(function(){
    stream.close();
    },2500);
    }
    },
    setFunction : function (){
    stream.watchTime += 1;
    if(stream.watchTime){
    clearTimeout(stream.info.schuler);
    }

    },
    getVideoStreamHtml:function(){
    return   '<script type="text/javascript">'
        +    'var flashvars={'
        +        'f:"'+stream.info.sourcevideolink+'",'
        +        'c:0,'
        +        'i:"http://b3.hoopchina.com.cn/web/widget/material/2015/2/pre2.jpg",'
        +        'p:1,'
        +        'h:3,'
        +        'loaded:stream.loadedHandler'
        +    '};'
        +    'var video=["'+stream.info.sourcevideolink+'->video/mp4"];'
        +    'CKobject.embed("http://b3.hoopchina.com.cn/web/widget/material/2015/2/ckplayer/ckplayer.swf","video1","ckplayer_video1","400","300",false,flashvars,video);'
        +    '</script>';
    }
    };

    stream.init({"width":"980","height":"400","sourcevideolink":"","sourcevideologourl":"","sourcevideologolink":"","bgcolor":"#fff","playtime":8000,"autoplaynum":"3","lifeday":"1","sourceurl":"http:\/\/i1.hoopchina.com.cn\/blogfile\/201612\/23\/BbsImg148250491932827_980x400.jpg","sourcelink":"\/\/goto.hupu.com\/?a=goClick&id=14147","isfloat":0,"isvideo":0,"type":"image","cookie":"stream-nba-239"});


